<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/%E6%AD%A6%E6%B1%8932x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/%E6%AD%A6%E6%B1%8916x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib1/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib1/pace/pace-theme-center-simple.min.css">
  <script src="/lib1/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="概述着色器initshader：初始化着色器。在固定管线中，绘制点、线简单方便，而在WebGL中绘制工作则被主要分解成顶点着色器与片元着色器。 在启动JS程序后，绘制工作首先进入的是顶点着色器，在顶点着色器中描述顶点特性（如位置、颜色等），顶点就是三维空间的点，比如三角形的三个顶点；然后进入到片元着色器，在片元着色器中逐片元处理像素（如光照、阴影、遮挡）。最后片元传入到颜色缓冲区，进行显示。渲染过">
<meta property="og:type" content="article">
<meta property="og:title" content="webgl编程指南初学">
<meta property="og:url" content="http://example.com/2021/09/15/webgl/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/index.html">
<meta property="og:site_name" content="Technological Blog">
<meta property="og:description" content="概述着色器initshader：初始化着色器。在固定管线中，绘制点、线简单方便，而在WebGL中绘制工作则被主要分解成顶点着色器与片元着色器。 在启动JS程序后，绘制工作首先进入的是顶点着色器，在顶点着色器中描述顶点特性（如位置、颜色等），顶点就是三维空间的点，比如三角形的三个顶点；然后进入到片元着色器，在片元着色器中逐片元处理像素（如光照、阴影、遮挡）。最后片元传入到颜色缓冲区，进行显示。渲染过">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/image/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/image-20210917153131886.png">
<meta property="article:published_time" content="2021-09-15T04:18:39.000Z">
<meta property="article:modified_time" content="2021-11-03T08:22:28.838Z">
<meta property="article:author" content="Li Yudong">
<meta property="article:tag" content="webgl初学">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/image/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/image-20210917153131886.png">

<link rel="canonical" href="http://example.com/2021/09/15/webgl/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>webgl编程指南初学 | Technological Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Technological Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">IT小白的成长之旅</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="tags fa-fw"></i>标签<span class="badge">18</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="th fa-fw"></i>分类<span class="badge">14</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="archive fa-fw"></i>归档<span class="badge">95</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/tiarmor1" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/09/15/webgl/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/author.jpg">
      <meta itemprop="name" content="Li Yudong">
      <meta itemprop="description" content="">
    </span>
    
    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Technological Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          webgl编程指南初学
        </h1>
    
        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
    
              <time title="创建时间：2021-09-15 12:18:39" itemprop="dateCreated datePublished" datetime="2021-09-15T12:18:39+08:00">2021-09-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-11-03 16:22:28" itemprop="dateModified" datetime="2021-11-03T16:22:28+08:00">2021-11-03</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/webgl/" itemprop="url" rel="index"><span itemprop="name">webgl</span></a>
                </span>
            </span>
    
          
    
        </div>
      </header>
    
    
    
    
    <div class="post-body" itemprop="articleBody">
    
      
        <h1 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h1><h2 id="着色器"><a href="#着色器" class="headerlink" title="着色器"></a>着色器</h2><p>initshader：初始化着色器。在固定管线中，绘制点、线简单方便，而在WebGL中绘制工作则被主要分解成顶点着色器与片元着色器。</p>
<p>在启动JS程序后，绘制工作首先进入的是顶点着色器，在顶点着色器中描述顶点特性（如位置、颜色等），顶点就是三维空间的点，比如三角形的三个顶点；然后进入到片元着色器，在片元着色器中逐片元处理像素（如光照、阴影、遮挡）。最后片元传入到颜色缓冲区，进行显示。渲染过程如下：</p>
<p><img src="/../../image/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/image-20210917153131886.png" alt="image-20210917153131886"></p>
<p>这个过程是一个类似水流的流向过程，所以这个过程被称为渲染管线（Pipeline）。并且，这个过程是需要我们去编程控制的，比如观察者的视角变化需要在顶点着色器去调控；光线对颜色的变化需要在片元着色器去调控等；因此，这个过程就是可编程管线。通过着色器程序，三维图像渲染就更加的灵活强大。</p>
<p>渲染管线是指将数据从3D场景转换成2D图像，最终在屏幕上显示出来的总过程。它分为几个阶段：应用阶段、几何阶段和光栅阶段。后面我们会将整个过程进行完整解析与描述。</p>
<h3 id="顶点着色器"><a href="#顶点着色器" class="headerlink" title="顶点着色器"></a>顶点着色器</h3><p>顶点着色器程序是嵌入在JS中的程序，所以虽然传入的是字符串，但其实本质是着色器描述语言（GLSL:OpenGL Shading Language）。既然是语言也就有自己的函数与变量定义。main（）函数是每个着色器程序定义的入口。在main函数中，将顶点的坐标赋值给内置变量gl_Position,点的尺寸赋值给内置变量gl_PointSize。顶点着色器一般用来对模型的顶点进行矩阵变换，一般就是将模型的所有顶点乘于一个变换矩阵，使该模型位于相对于WebGL坐标系中的某个位置。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 顶点着色器程序</span></span><br><span class="line"><span class="keyword">var</span> VSHADER_SOURCE = </span><br><span class="line">  <span class="string">'void main() &#123;\n'</span> +</span><br><span class="line">  <span class="string">'  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n'</span> + <span class="comment">// Set the vertex coordinates of the point</span></span><br><span class="line">  <span class="string">'  gl_PointSize = 10.0;\n'</span> +                    <span class="comment">// Set the point size</span></span><br><span class="line">  <span class="string">'&#125;\n'</span>;</span><br></pre></td></tr></table></figure>

<p><strong>片元着色器</strong></p>
<p>得到光栅化的片段像素位置数据之后，就可以通过片段着色器为这些像素进行上色了，这是第二个可以编程的地方；我们可以对图片进行采样之后，在这里进行上色。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 片元着色器程序</span></span><br><span class="line"><span class="keyword">var</span> FSHADER_SOURCE =</span><br><span class="line">  <span class="string">'void main() &#123;\n'</span> +</span><br><span class="line">  <span class="string">'  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n'</span> + <span class="comment">// Set the point color</span></span><br><span class="line">  <span class="string">'&#125;\n'</span>;</span><br></pre></td></tr></table></figure>

<h2 id="渲染管线"><a href="#渲染管线" class="headerlink" title="渲染管线"></a>渲染管线</h2><p>上面已经说过，渲染管线其实就是一个图形渲染的流水线过程，这里我们分步骤一个个进行解析。</p>
<h3 id="1-顶点着色器"><a href="#1-顶点着色器" class="headerlink" title="1.顶点着色器"></a>1.顶点着色器</h3><p>顶点着色器一般用来对模型的顶点进行矩阵变换，一般就是将模型的所有顶点乘于一个变换矩阵，使该模型位于相对于WebGL坐标系中的某个位置。</p>
<p>顶点着色器是可编程的，使用的语言是 GLSL 来进行编写，下面我们主要说一下几种常用的属性类型：</p>
<ul>
<li>attribute变量：用户自定义变量，一般是存储顶点属性的变量；</li>
<li>uniform变量：恒值变量，一般表示每个顶点都一致的变量，比如变换矩阵、光照等；</li>
<li>varying变量：易变变量，将顶点着色器的数据传递给片段着色器时使用；</li>
<li>内置常量：WebGL 内部的常量；</li>
</ul>
<h3 id="2-图元装配"><a href="#2-图元装配" class="headerlink" title="2.图元装配"></a>2.图元装配</h3><p>这个阶段，GPU会将我们传入的顶点装配成三角形、线段或者点；装配好之后，会自动截去不在可视区域内的信息；</p>
<h3 id="3-光栅化"><a href="#3-光栅化" class="headerlink" title="3.光栅化"></a>3.光栅化</h3><p>这个阶段，GPU会将装配好的三角形转换成对应的像素，并将这些像素传入下一个阶段；</p>
<h3 id="4-片段着色器"><a href="#4-片段着色器" class="headerlink" title="4.片段着色器"></a>4.片段着色器</h3><p>得到光栅化的片段像素位置数据之后，就可以通过片段着色器为这些像素进行上色了，这是第二个可以编程的地方；</p>
<p>我们可以对图片进行采样之后，再这里进行上色；</p>
<h3 id="5-逐片段操作"><a href="#5-逐片段操作" class="headerlink" title="5.逐片段操作"></a>5.逐片段操作</h3><p>本步骤包含了多个子操作，每个操作都会影响当前片段最终的显示效果，下面我们看下几个常见的子操作：</p>
<h3 id="6、帧缓存"><a href="#6、帧缓存" class="headerlink" title="6、帧缓存"></a>6、帧缓存</h3><p>数据经过整个渲染管线处理之后，最终会写入到帧缓存中，帧缓存存储了最终会显示到屏幕上的颜色数据。</p>
<p>帧缓存包含了 3 个具体的缓存：</p>
<h4 id="1-颜色缓存"><a href="#1-颜色缓存" class="headerlink" title="1.颜色缓存"></a>1.颜色缓存</h4><p>存储每个像素点的具体颜色值的缓存，常见的具体格式可以分为：</p>
<ul>
<li>16位：RGB565，红色5位，绿色6位，蓝色5位，不保存透明通道（之所以绿色多1位是因为人眼对绿色更加敏感）；</li>
<li>24位：RGB888，红色8位，绿色8位，蓝色8位，不保存透明通道；</li>
<li>32位：RGBA8888，红色8位，绿色8位，蓝色8位，透明通道8位；</li>
</ul>
<h4 id="2-Z-缓存（深度缓存）"><a href="#2-Z-缓存（深度缓存）" class="headerlink" title="2.Z-缓存（深度缓存）"></a>2.Z-缓存（深度缓存）</h4><p>存储每个像素点的深度，用来决定是丢弃当前像素颜色还是保留，假设，新渲染的颜色在旧颜色的前面，那么就覆盖旧颜色，如果新颜色在旧颜色的后面（被遮挡了）则保留旧颜色。</p>
<h4 id="3-模板缓存"><a href="#3-模板缓存" class="headerlink" title="3.模板缓存"></a>3.模板缓存</h4><p>用来控制颜色缓存某个位置的写入操作，常用来处理阴影。</p>
<h2 id="canvas"><a href="#canvas" class="headerlink" title="canvas"></a>canvas</h2><p>一般情况下，在canvas标签实现绘图的步骤如下：1、获取canvas元素；2、向该元素请求二维图形的“绘图上下文”；3、在绘图上下文上调用相应的绘图函数，以绘制二维图形。</p>
<p>canvas本质上是提供一种上下文的机制来进行绘图的，利用canvas.getContext获取上下文，之后再用上下文支持的方法绘图。</p>
<h3 id="着色器-1"><a href="#着色器-1" class="headerlink" title="着色器"></a>着色器</h3><p>在代码中，着色器程序是以字符串的形式嵌入在JS文件中的，在程序真正开始运行前就设置好了。WebGL中着色器分两种，顶点着色器与片元着色器。顶点着色器指定了点的位置与尺寸，片元着色器指定了点的颜色；顶点着色器逐顶点操作，片元着色器逐片元操作，一旦顶点着色器执行完之后，片元着色器就会开始执行。</p>
<h3 id="坐标系统"><a href="#坐标系统" class="headerlink" title="坐标系统"></a>坐标系统</h3><p>WEBGL使用三维坐标系统，即笛卡尔坐标系，又称右手坐标系。而WEBGL的坐标系与canvas绘图区的坐标系不同，需要将前者映射到后者。</p>
<h3 id="数据传输"><a href="#数据传输" class="headerlink" title="数据传输"></a>数据传输</h3><p>物体绘制的关键在于：WebGL如何在JS程序与着色器程序之间传输数据。有两种</p>

    </div>
    
    
    
    
    <div>
      
        <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

      
    </div>
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/alipay.png" alt="Li Yudong 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>Li Yudong
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://example.com/2021/09/15/webgl/webgl%E6%96%B0%E6%89%8B%E6%95%99%E7%A8%8B/" title="webgl编程指南初学">http://example.com/2021/09/15/webgl/webgl新手教程/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>

    
      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/webgl%E5%88%9D%E5%AD%A6/" rel="tag"># webgl初学</a>
          </div>
    
        

    
        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/09/10/%E5%AD%A6%E6%A0%A1%E9%A1%B9%E7%9B%AE%E5%BA%94%E7%94%A8/%E6%BB%91%E5%8A%A8%E5%9B%BE%E7%89%87%E9%AA%8C%E8%AF%81%E7%A0%81/" rel="prev" title="滑动图片验证码">
      <i class="fa fa-chevron-left"></i> 滑动图片验证码
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/09/16/webgl/three.js%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97/" rel="next" title="three.js初学">
      three.js初学 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#概述"><span class="nav-number">1.</span> <span class="nav-text">概述</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#着色器"><span class="nav-number">1.1.</span> <span class="nav-text">着色器</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#顶点着色器"><span class="nav-number">1.1.1.</span> <span class="nav-text">顶点着色器</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#渲染管线"><span class="nav-number">1.2.</span> <span class="nav-text">渲染管线</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-顶点着色器"><span class="nav-number">1.2.1.</span> <span class="nav-text">1.顶点着色器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-图元装配"><span class="nav-number">1.2.2.</span> <span class="nav-text">2.图元装配</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-光栅化"><span class="nav-number">1.2.3.</span> <span class="nav-text">3.光栅化</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-片段着色器"><span class="nav-number">1.2.4.</span> <span class="nav-text">4.片段着色器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-逐片段操作"><span class="nav-number">1.2.5.</span> <span class="nav-text">5.逐片段操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6、帧缓存"><span class="nav-number">1.2.6.</span> <span class="nav-text">6、帧缓存</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-颜色缓存"><span class="nav-number">1.2.6.1.</span> <span class="nav-text">1.颜色缓存</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-Z-缓存（深度缓存）"><span class="nav-number">1.2.6.2.</span> <span class="nav-text">2.Z-缓存（深度缓存）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-模板缓存"><span class="nav-number">1.2.6.3.</span> <span class="nav-text">3.模板缓存</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#canvas"><span class="nav-number">1.3.</span> <span class="nav-text">canvas</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#着色器-1"><span class="nav-number">1.3.1.</span> <span class="nav-text">着色器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#坐标系统"><span class="nav-number">1.3.2.</span> <span class="nav-text">坐标系统</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数据传输"><span class="nav-number">1.3.3.</span> <span class="nav-text">数据传输</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Li Yudong"
      src="/images/author.jpg">
  <p class="site-author-name" itemprop="name">Li Yudong</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">95</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">18</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/tiarmor1" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;tiarmor1" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:1157019137@qq.com" title="E-Mail → mailto:1157019137@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 2020 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Li Yudong</span>
</div>

        








      </div>
    </footer>
  </div>

  
  
  <script color='0,0,0' opacity='0.5' zIndex='-1' count='150' src="/lib1/canvas-nest/canvas-nest.min.js"></script>
  <script src="/lib1/anime.min.js"></script>
  <script src="/lib1/velocity/velocity.min.js"></script>
  <script src="/lib1/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

  
   <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas> 
   <script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
   <script type="text/javascript" src="/js/fireworks.js"></script>
  
</body>
</html>

